<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>表单列表渲染</title>
<{$showjs}>
<link rel="stylesheet" type="text/css" href="/Plug-in/ext/resources/css/xtheme-slate.css" />
<link rel="stylesheet" type="text/css" href="../css/main1.css" />
<script type="text/javascript" src="/Plug-in/ext/Ext.grid.CheckColumn.js"></script>
<script type="text/javascript" src="/Plug-in/ext/Ext.Store.Sort.js"></script>
<script type="text/javascript" src="/Plug-in/ext/Ext.form.Property.js"></script>
<style type="text/css">
.add{background:url(../img/shield_add.png) no-repeat 1px 2px !important;}
.copy{background:url(../img/copy.gif) no-repeat 1px 2px !important;}
.del{background:url(../img/shield_delete.png) no-repeat 1px 2px !important;}
.edit{background:url(../img/shield_go.png) no-repeat 1px 2px !important;}
.search{background:url(../img/find.gif) no-repeat 1px 2px !important;}
.hidea{background:url(../img/arrow_out.png) no-repeat 1px 2px !important;}
.hideb{background:url(../img/arrow_in.png) no-repeat 1px 2px !important;}
.fsadd{background:url(../img/icon_extension.gif) no-repeat 1px 2px !important;}
.fslist{background:url(../img/list_extensions.gif) no-repeat 1px 2px !important;}

.x-check-group-alt {
            background: #D1DDEF;
            border-top:1px dotted #B5B8C8;
            border-bottom:1px dotted #B5B8C8;
        }
</style>
<script language="javascript">
function gxzd(id,zd,xz){
												
				Ext.Ajax.request({
					waitMsg:'数据处理中...',
					url:'./i.php',
					method:'POST',
					params:{
						op:'gxzd',
						id:id,
						tname:'<{$table.tabname}>',
						zd:zd,
						xz:xz
					},
					success:function(response){
						 top.gridrefresh();

					},
					failure:function(response){
						Ext.MessageBox.alert('警告',"无法连接数据库!");
					}
		
				});
		}
function tjpx(tid,zd){
					var pr=top.Ext.get('px'+tid+zd);
						if(pr){
							pr.close();
							}
						top.xajax_loadUrl('拖拽排序-'+tid+'_'+zd,'./show1/px.php?&op=show&tid='+tid+'&zd='+zd,'416',top.Ext.getBody().getHeight(),false,'px'+tid+zd);
		}

<!--
Ext.onReady(function (){

//信息提示选项   
Ext.QuickTips.init();
Ext.form.Field.prototype.msgTarget = 'side';//设置提示信息位置为边上
//信息提示选项end
	var myMask = new Ext.LoadMask(Ext.getBody(), {
                        msg: '请稍候...',
                        removeMask: true
                    });
//grid 复选栏控件
	 var checkColumn = new Ext.grid.CheckColumn({
       header: "Indoor",
       dataIndex: 'indoor',
       width: 55
    });
//grid 复选栏控件end

//ds 参数
	var data = {url : "./l.php" , method:'POST'};//异步参数
	var requestParams = {op : 'fy',tid:<{$tree.id}> ,bdtid:'<{$bdtid}>' , bdid :'<{$bdid}>',dbname:'<{$table.tabname}>'}; //请求参数,store 每次请求都发送的参数,可在这里设定,id gid sortid 等信息
	var sm = new Ext.grid.CheckboxSelectionModel();
//cm 参数
	var cmCfg = [
//					checkColumn,
					sm,//原样写就可以
					{header:'ID',dataIndex:'id',width:50,sortable:true,readOnly:true},
					<{section name=li loop=$xr}>
					{id:'<{$xr[li].id}>',header:'<{$xr[li].name}>',dataIndex:'<{$xr[li].fname}>',width:<{$xr[li].wd}>,sortable:true<{if $xr[li].renderer neq ''}><{$config[li].renderer}><{/if}>}
					<{if $smarty.section.li.index+1 < $xr|@count}>,<{/if}>
					<{/section}>
				];


//ds解析模型 用于ds 的reader
	var robj = [		
//	{name: 'indoor', type: 'bool'},
			new Ext.grid.RowNumberer(),//原样写就可以
            {name: 'id'},
			<{section name=li loop=$xr}>
			{name:'<{$xr[li].fname}>'}
			<{if $smarty.section.li.index+1 < $xr|@count}>,<{/if}>
			<{/section}>
        ];

// ds reader
	var rd = new Ext.data.JsonReader({
		totalProperty:'total',
		root:'data',
		id:'jsonreader'
	},robj);



	var ds = new Ext.data.Store({
		proxy: new Ext.data.HttpProxy(data),
		reader:rd,
		baseParams:requestParams,
		sortInfo:{field :'id',direction:'DESC'}
	});


	var cm = new Ext.grid.ColumnModel(cmCfg);


	var advSearchForm=new Ext.FormPanel({
			id:'advSearchForm',
			name:'advSearchForm',
			labelWidth:55,
			border:false,
			autoScroll:true,
			autoHight:true,
			labelAlign:'right',
			bodyStyle:'padding:5px',
			buttunAlign:'left',
			layout:'form',
				plain:true,
				frame:true,
			items:[
				   {
						xtype:'hidden',
			            name: 'tid',
			            value:'<{$tree.id}>'
		    },{
						xtype:'hidden',
			            name: 'bdtid',
			            value:'<{$bdtid}>'
		    },{
						xtype:'hidden',
			            name: 'bdid',
			            value:'<{$bdid}>'
		    }
            <{section name=li loop=$js}>
				,<{$js[li]}>
           <{/section}>
			],
		buttons:[
			{text:'搜索',iconCls:'search',handler:function (){
				
/*					for (elm in advSearchForm.getForm().getValues(false)) {
						alert(elm); 
						}   
*/
			var searchobj=advSearchForm.getForm().getValues(false);
//			alert(advSearchForm.getForm().getValues(true));
			searchobj.start=0;
			searchobj.limit=10;
			//alert(searchobj);
			    ds.load({
					params:searchobj
				});
				advSearchwin.hide();
			}},
			{text:'取消',handler:function (){
				advSearchForm.form.reset();
//			    advSearchwin.hide();
			}}
		]
	});
	var advSearchwin=new Ext.Window({
		title:'高级搜索',
		id:'advSearchwin',
		 collapsible : true,
/*			tools : [ 
				{id:'toggle'}, 
				{id:'close'}, 
				{id:'maximize'} 
			   ], */
		width:400,
		autoHight:true,
		closeAction:'hide',
		plain:true,
		items:advSearchForm
	});



   var adstatus=0;
function searchHandeler(){
   advSearchwin.show();
   adstatus=1
}

function delHandeler(){
	if(grid.selModel.getCount()==1){
		Ext.MessageBox.confirm("操作确认","你确认删除当前选择项目?",delTask);
	}else if(grid.selModel.getCount()>1){
		Ext.MessageBox.confirm("警告","你确认删除选中的项目?",delTask);
	}else{
		Ext.MessageBox.alert('消息',"你没有选中项目");
	}  
}
function editHandeler(){
	if(grid.selModel.getCount()==1){
		var selections = grid.selModel.getSelections();
		
		 parent.tabs.add({
            iconCls: 'useradd',
           	html:'<iframe height="100%"   frameborder="0" width="100%" marginheight="0" marginwidth="0" scrolling="auto" src="./right.php?op=add&tid=64&id='+selections[0].json.id+'"></iframe>',
            closable:true,
            title: '编辑'+selections[0].json.tt+''
        }).show();
	}else if(grid.selModel.getCount()>1){
		Ext.MessageBox.alert("提示","本操作无法批量完成");
	}else{
	 Ext.Msg.alert("提示消息","请选择一行数据然后才能够编!");return false;
	}
}
function fsadd(fstid,title,url,id){
					var pr=top.Ext.get('adddata'+fstid);
						if(pr){
							pr.close();
							}
						top.xajax_loadUrl('添加绑定数据-'+title,url+id,top.Ext.getBody().getWidth(),top.Ext.getBody().getHeight(),false,'adddata'+fstid);
}
function fslist(fstid,title,url,id){
					var pr=top.Ext.get('list'+fstid);
						if(pr){
							pr.close();
							}
						top.xajax_loadUrl('浏览绑定数据-'+title,url+id,top.Ext.getBody().getWidth(),top.Ext.getBody().getHeight(),false,'list'+fstid);
}

//删除处理
function delTask(btn){
    if (btn=='yes'){
		var selections = grid.selModel.getSelections();
         var prez = [];
         for(i = 0; i< grid.selModel.getCount(); i++){
          prez.push(selections[i].json.id);
         }

		var encoded_array= Ext.encode(prez);

		Ext.Ajax.request({
			waitMsg:'正在操作',
			url:'./l.php',
			method:'POST',
			params:{
				op:'del',
				ids:encoded_array,
				dbname:'<{$table.tabname}>'
			},
			success:function(response){
					Ext.MessageBox.alert('消息',"数据删除成功！");
					ds.reload();
					grid.refresh();
			},
			failure:function(response){
				Ext.MessageBox.alert('警告',"无法连接数据库!");
			}

		});

    }
}
//删除end
//edit
var oneTbar=new Ext.Toolbar({   
     items:[   
        {text:'当前页利润：<font color=red>45</font>元',id:'dq'},   
        {text:'总利润：<font color=red>145</font>元',id:'zong'}
     ]     
});   

//标题搜索
var sbar=new Ext.FormPanel({
        baseCls: 'x-plain',
		bodyStyle:'padding:5px 0 0 0',
        defaults: {width:150},
		labelWidth:80,
        defaultType: 'textfield',
        items: [{
                fieldLabel: '权限组检索',
                id:'tt',
                name: 'tt'
            }]
    });
var searObj= {
				text: '搜索',
				iconCls:'search',
				handler:function(){
					ds.load({
							params:{
								tt:Ext.get('tt').dom.value,start:0,limit:10
							}
					})
				}
			};
//标题搜索end


	var grid = new Ext.grid.GridPanel({
		el:'cms-grid-el',
		id:'cms-grid-id',
//		plugins:checkColumn,
		clicksToEdit:1,
		ds:ds,
		cm:cm,
		sm:sm,//selModel:new Ext.grid.RowSelectionModel({singleSelect:false}),
		tbar: [
			sbar,
			searObj,
			<{if ($tree.id|getright:"c")}>
			new Ext.Toolbar.Separator(),
			{text:'添加',iconCls:'add',handler:function(){
					 parent.tabs.add({
						title: '添加新的权限组',
						iconCls: 'useradd',
						html:'<iframe height="100%"   frameborder="0" width="100%" marginheight="0" marginwidth="0" scrolling="auto" src="./right.php?op=add&tid=64"></iframe>',
						closable:true
					}).show();
									}},<{/if}>
									<{if ($tree.id|getright:"u")}>
			new Ext.Toolbar.Separator(),
			{text:'编辑',iconCls:'edit',handler:editHandeler},<{/if}>
<{if ($tree.id|getright:"d")}>			new Ext.Toolbar.Separator(),
			{text:'删除',iconCls:'del',handler:delHandeler},
			<{/if}>
			new Ext.Toolbar.Separator(),
			{text:'刷新',iconCls:'i_czxt',handler:function (){
				window.location.reload();
			}}
		],
/*		listeners   : {   
               'render': function(){   
                    oneTbar.render(this.bbar);      //add one tbar   
                }   
            },
*/		bbar: new Ext.PagingToolbar({
			pageSize: 10,
			store: ds,
			displayInfo: true,
			displayMsg: '显示第 {0} 条到 {1} 条记录，一共 {2} 条',
			emptyMsg: "没有记录"
		}),
		autoWidth:true,
		width:Ext.getBody().getWidth(),
		autoHeight:true,
		autoShow:true,
		frame:true,
//		autoExpandColumn:true,
		autoDestroy:true,
		cls:'',//extra css 
		loadMask:{msg:"正在加载数据..."}
//		default:{width:50}
	});

	ds.load({params:{start:0,limit:10}});
	grid.render();
		grid.on('columnresize',function(columnIndex,newSize){
		var column_id=cm.getColumnId(columnIndex);
		myMask.show();
		Ext.Ajax.request(
					                {
					                    waitMsg:'正在提交....',
					                    method:'POST',
					                    params:{op:'width_change',id:column_id,width:newSize},
					                    url:'l.php',
					                    success:function(form, action) {
											myMask.hide();
					                    },
					                    failure: function(form, action) {
					                    }
					                }
					            );
	});
	<{if ($tree.id|getright:"u")}> grid.on('celldblclick', editHandeler); <{else}>
	grid.on('celldblclick', function(){Ext.MessageBox.alert('警告','没有编辑权限')});
	<{/if}>

/*ds.on('datachanged',function(){
	Ext.getCmp('dq').setText("当前页利润：<font color=red>"+rd.jsonData.as+"</font>元");
	Ext.getCmp('zong').setText("当前页利润：<font color=red>"+rd.jsonData.as*2+"</font>元");
							});
*/ds.on('beforeload',function(){
Ext.apply(
      this.baseParams,
      {
		tt:Ext.get('tt').dom.value<{section name=li loop=$ckbox}>,
		'<{$ckbox[li]}>':''<{/section}>
      });
	  //alert(advSearchForm.getForm().getValues(false));
      if(adstatus!=0){
	  Ext.apply(
      this.baseParams,
		advSearchForm.getForm().getValues(false));
	
	  }

    });


grid.on("rowcontextmenu",function(grid,rowIndex,e){ 
e.preventDefault();if(rowIndex<0){return;} 
var treeMenu = new Ext.menu.Menu 
([<{if ($tree.id|getright:"c")}> 
{xtype:"button",text:"添加",iconCls:"add",pressed:true,handler:function(){
		 parent.tabs.add({
            title: '添加新的权限组',
            iconCls: 'useradd',
           	html:'<iframe height="100%"   frameborder="0" width="100%" marginheight="0" marginwidth="0" scrolling="auto" src="./right.php?op=add&tid=64"></iframe>',
            closable:true
        }).show();
	}}, <{/if}>
{xtype:"button",text:"刷新",iconCls:"i_czxt",pressed:true,handler:function(){
		window.location.reload();
	}}<{if ($tree.id|getright:"d")}>, 
{xtype:"button",text:"删除",iconCls:"del",pressed:true, handler:function(){
			var record = grid.getStore().getAt(rowIndex); 
			Ext.Ajax.request({
			waitMsg:'正在操作',
			url:'./l.php',
			method:'POST',
			params:{
				op:'del',
				ids:"["+record.data.id+"]",
				dbname:'<{$table.tabname}>'
			},
			success:function(response){
					Ext.MessageBox.alert('消息',"数据删除成功！");
					ds.reload();
					grid.refresh();
			},
			failure:function(response){
				Ext.MessageBox.alert('警告',"无法连接数据库!");
			}

		});
	}}<{/if}><{$fstree}> 
]); 
treeMenu.showAt(e.getPoint()); 
}); 


});
//-->
</script>

</head>

<body>
	<div id="cms-grid-el">
	 
	</div>
</body>
</html>